﻿CREATE procedure FC_Forecast_Insert
@IdUsuario int, 
@IdCustomer int,
@IdPeriod int, 
@IdProduct int, 
@Volume int
as
DECLARE @IDSysId INT

begin transaction
	insert into FC_Forecast (IdUsuario, IdCustomer, IdPeriod, IdProduct, Volume, DateIng, DateMod)
	values(@IdUsuario, @IdCustomer, @IdPeriod, @IdProduct, @Volume, getdate(), getdate())


-- Valida error
if @@error <> 0 goto errHanler 
SELECT @IDSysId = @@IDENTITY
commit transaction

Return @IDSysId
 
errHanler:
rollback transaction




Return @IDSysId